from mistralai.async_client import MistralAsyncClient
from mistralai.models.chat_completion import ChatMessage
from auth_tmp import api_key
import asyncio as a

model = "mistral-large-latest"

client = MistralAsyncClient(api_key=api_key)

messages = [
    ChatMessage(role="user", content="你好！")
]

# With async
async_response = client.chat_stream(model=model, messages=messages)

async def main():
    async for chunk in async_response: 
        print(chunk.choices[0].delta.content, end='', flush=True)
    print('\n<Over>')
        
a.run(main())
